$(function () {
    //获得积分
    if(type==1){
        listIntegraleAjax(1);
    }else{
        listIntegralExchangeAjax(1);
    }

    //兑换人民币
$("body").on("click",".tab-link",function(){
    $(".tab-link").forEach(function(item,index){
        $(item).removeClass("active");
    });
    $(this).addClass("active");
    var type=$(this).data("id");
    if(type==1){
        listIntegraleAjax(1);
    }else{
        listIntegralExchangeAjax(1);
    }
}).on("click",'.camilo',function(){
        toView($(this))
    }).on("click",'.checkDelivery',function(){
      var number =  $(this).data("number");
        var html="<p>快递单号</p><p>单号："+number+"</p>"
        Zepto.alert(html);
    });



    function  toView(that){
        var id = that.data("id");
        var name = that.data("name");
        $.ajax({
            url: baseloaction + "/mobile/uc/integral/checkTheCard",
            data: {"id": id},
            type: "post",
            dataType: "json",
            success: function (result) {
                if(result.success){
                    var html="<p>"+name+"</p><p>账号："+result.entity.account+"</p><p>密码："+result.entity.camilo+"</p>"
                    Zepto.alert(html);
                }else{
                    Zepto.toast( result.message);
                }
            },
            error: function (error) {
                Zepto.toast("系统繁忙,请稍后重试");
            }
        })
    }


    function listIntegraleAjax(pageNo) {
        $("#exchangerecord-list").html("");
        $("#exchangerecord-list").parent("div").addClass("hide");
        $("#shop-list").removeClass("hide");
        var params = {};
        params = JSON.stringify(params);
        loadMobilePathData({
            url: baseloaction + '/mobile/uc/integral/integralShopAjax',
            contextId: 'shop-list',
            pageNo: pageNo,
            pageCall: listIntegraleAjax,
            params: params,
            callback: function (pageNo) {

            }
        });
    }

    function listIntegralExchangeAjax(pageNo) {
        $("#shop-list").html("");
        $("#shop-list").addClass("hide");
        $("#exchangerecord-list").parent("div").removeClass("hide");
        var params = {};
        params = JSON.stringify(params);
        loadMobilePathData({
            url: baseloaction + '/mobile/uc/integral/listIntegralExchangeAjax',
            contextId: 'exchangerecord-list',
            pageNo: pageNo,
            pageCall: listIntegralExchangeAjax,
            params: params,
            callback: function (pageNo) {

            }
        });
    }

});
